package com.example.tian.securityinspection.network;

import android.util.Log;

import com.example.tian.securityinspection.model.bean.ResponseError;

import rx.Subscriber;

public abstract class RequestCallback<T> extends Subscriber<T> {

    private static final String TAG = "RequestCallback";

    @Override
    public void onNext(T t) {
        onResponse(t);
    }

    @Override
    public void onError(Throwable throwable) {
        if (throwable instanceof ResponseError){
            onFailure((ResponseError)throwable);
        }else {
            Log.e(TAG,"throwable isn't instance of ResponseError");
        }
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onCompleted() {

    }

    public void onResponse(T response){}

    public void onFailure(ResponseError error){}

}
